<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数二</title>
</head>
<body>
<script>
    /*可变长度长的函数*/
    function sum(a, b, ...m) {
        // console.log("a=" + a)
        // console.log("b=" + b)
        // console.log("m=" + m) //获取到m是一个除了a,b之外其他所有数字组成的数组
        //return a + b
        //return a + b + m;
        let n = 0
        for (let i = 0; i < m.length; i++) {
            n += m[i]
        }

        return a + b + n
    }

    // let k = sum(5, 6, 7, 10);
    // console.log(k)
    sum(5)
    console.log("-------------------------------")
    sum(5,7)
    console.log("==========================")
    sum(5,6,7,10,12,18)
    console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~")
    console.log(sum(1,2,3,4,5,6,7,8,9,10))


</script>
</body>
</html>